<template>
  <el-aside :width="isCollapse ? '60px' : '200px'" height="100%">
    <div class="menu_top" @click="toggleMenu">| | |</div>
    <el-menu
      router
      :default-active="activePath"
      @select="selectMenu"
      :collapse="isCollapse"
      class="el-menu-vertical-demo"
      text-color="black"
      background-color="#545c64"
      active-text-color="#ffd04b"
    >
      <el-menu-item index="/home">
        <i class="el-icon-menu"></i>
        <span slot="title">首页</span>
      </el-menu-item>
      <el-submenu index="">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>资金管理</span>
        </template>
        <el-menu-item index="/funds">资金流水</el-menu-item>
      </el-submenu>
      <el-submenu index="3">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>信息管理</span>
        </template>
        <el-menu-item index="/info">个人信息</el-menu-item>
      </el-submenu>
    </el-menu>
  </el-aside>
</template>

<script>
export default {
  data() {
    return {
      isCollapse: false, //   false 展开     true 合并
      activePath: "",
    };
  },
  created() {
    this.activePath = sessionStorage.getItem("activePath");
  },

  methods: {
    // 缩放
    toggleMenu() {
      this.isCollapse = !this.isCollapse;
    },
    // 点击左侧栏
    selectMenu(path) {
      this.activePath = path;
      sessionStorage.setItem("activePath", path);
    },
  },
};
</script>

<style lang="scss" scoped>
.menu_top {
  color: white;
  text-align: center;
}
</style>